#include<bits/stdc++.h>
using namespace std;
int T;
int n,b=1;
int A[1000001];
int Aa[1000001];

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    for (int i=0;i<T;T++){
        cin>>n;
        for (int j=0;j<n;j++){
            cin>>A[j];
            Aa[j]=1;
        }
        for (int j=0;j<n;j++){
            for (int k=0;k<n;k++){
                if (A[j]==A[k]){
                    b=0;
                }
            }
        }
        if (b==1){
            cout<<0;
            return 0;
        }
        for (int j=0;j<n;j++){
            for (int k=j+1;k<n;k++){
                if (A[j]==A[k] && Aa[k]==1){
                    int ans=ans+A[j];
                    Aa[k]=0;
                }
            }
        }
    }
    return 0;
}
